#include<linux/module.h>
#include<linux/fs.h>
#include<linux/init.h>
#include<linux/list.h>
#include<linux/spinlock.h>
#include<linux/kdev_t.h>

#define SUPER_BLOCKS_ADDRESS  				(0xc177ce0c)
#define SB_LOCK_ADDRESS     				(0xc1937aa0)

static int __init my_init(void)
{
    struct super_block *sb = NULL;
    struct list_head *pos = NULL;
    struct list_head *linode = NULL;
    struct inode *pinode = NULL;
    unsigned long long count = 0;

    printk("\nInit begin: Print some fields of super_blocks---------------------->\n");
    spin_lock((spinlock_t *)SB_LOCK_ADDRESS);
    list_for_each(pos,(struct list_head * )SUPER_BLOCKS_ADDRESS){
        sb = list_entry(pos,struct super_block,s_list);
        printk("dev_t:%d:%d\n",MAJOR(sb->s_dev),MINOR(sb->s_dev));
        printk("file_type name:%s\n",sb->s_type->name);
        list_for_each(linode,&sb->s_inodes){
            pinode = list_entry(linode,struct inode,i_sb_list);
            count++;
            printk("%lu\t\n",pinode->i_ino);
        }
    }
    spin_unlock((spinlock_t * )SB_LOCK_ADDRESS);
    printk("the number of inodes:%llu\n", count);
    printk("\nInit end: bye---------------------->\n");
    return 0;
}
static void __exit my_exit(void)
{
    printk("unloading...\n");
}
module_init(my_init);
module_exit(my_exit);
MODULE_LICENSE("GPL");

